<template>
  <div class="scroll">
    <ul>
      <li v-for="item in ChoicenessData" :key="item.goodsid">
        <img v-lazy="item.pic" />
        <div class="title">
          <img src="@/assets/images/3.png" alt="" />
          <span class="name">{{ item.dtitle | mysub(8) }}</span>
        </div>
        <div class="pic">
          <span>劵后</span>
          <span class="yuan">￥{{ item.yuanjia }}</span>
        </div>
        <div class="quan">
          <span class="one">劵</span>
          <span class="two">{{ item.quanJine }}元</span>
        </div>
        <div class="sell">已售{{ item.xiaoliang }}</div>
      </li>
    </ul>

  </div>
</template>

<script>
import { getChoiceness } from "@/api/detail";
import BetterScroll from "better-scroll";
export default {
  data() {
    return {
      ChoicenessData: [],
      pageNo: 1,
    };
  },
  mounted() {
    this.onLoad();
  },
  updated() {
    this.$nextTick(() => {
      let bs = new BetterScroll(".scroll", {
        pullUpLoad: true,
        pullDownRefresh: true,
      });
      bs.on("pullingUp", () => {
        console.log(111);
        this.onLoad();
        bs.finishPullUp();
      });
      bs.on("pullingDown", () => {
        this.onLoad();
        // 告诉当前事件完成了
        bs.finishPullDown();
      });
    });
  },
  methods: {
    async onLoad() {
      let pageNo = this.pageNo;
      let ret = await getChoiceness(pageNo);
      let rets = ret.data.lists;
      if (rets.length > 0) {
        this.pageNo++;
        this.ChoicenessData = [...rets, ...this.ChoicenessData];
        console.log(this.ChoicenessData);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.scroll{
    height: 800px;
    overflow: hidden;
}
ul {
  display: flex;
  flex-wrap: wrap;
  align-content: space-around;
  background: #f5f5f9;
}
ul li {
  width: 160px;
  height: 280px;
  margin: 0 10px 10px 15px;
  background: #fff;
}
ul li img {
  width: 160px;
  height: 160px;
}
.title {
  width: 160px;
  height: 15px;
  line-height: 15px;
  margin-top: 15px;
  padding: 0 10px;
  margin-bottom: 15px;
}
.title img {
  width: 29px;
  height: 13px;
  margin-right: 5px;
}
.title .name {
  font-size: 13px;
  color: #333;
}
.pic {
  color: #666;
  font-size: 13px;
  padding: 0 10px;
  margin-bottom: 5px;
}
.pic .yuan {
  color: #ff2b22;
  font-size: 18px;
}
.quan {
  padding: 0 10px;
  margin-bottom: 5px;
}
.quan .one {
  display: inline-block;
  width: 13px;
  height: 13px;
  color: #fe3a33;
  background: #fff;
  border-radius: 1px 0 0 1px;
  border: 1px solid #fe3a33;
}
.quan .two {
  display: inline-block;
  width: 30px;
  height: 15px;
  background: linear-gradient(90deg, #ff8873 0, #ff4f4f 100%);
  border-radius: 2px;
  color: #fff;
}
.sell {
  padding: 0 10px;
  color: #666;
}
</style>